/**
 * COPYRIGHT© KMTC 2007
 * This software is the proprietary information of Korea Marine Transport Co.LTD
 * 
 * Revision History
 * Author			Date		Description
 * ------			----		-----------
 * 강성?��@wees.co.kr		
 */

package kr.or.javacafe.common.util;

import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

public class ListSessionManager {


	/**
	 * ?��?��?�� ?��?��?�� 리스?�� ?��?��?�� ?���?
	 * @param request ?��?��?�� request
	 * @param list    리스?�� ?��?��?��
	 */
	public static void setUsersession(HttpServletRequest userrequest, List list) {
		/*?��?�� setting*/
		HttpSession usersession = userrequest.getSession();

		if(usersession.getAttribute("SESSION_DATA_LIST")!=null){
			usersession.removeAttribute("SESSION_DATA_LIST");
		}
		usersession.setAttribute("SESSION_DATA_LIST", list);
		
	}
	
	
	public static String pagNavigator(int currentpage, List list){

		StringBuffer nav=new StringBuffer();
		nav.append("<table height=\"35\"  border=\"0\" align=\"center\"  cellpadding=\"0\" cellspacing=\"0\"> \n");
		nav.append("<tr> \n");
		nav.append("<td width=\"20\" align=\"center\">");
		
		for(int i=0; i<list.size(); i++){
			if(i == currentpage){
				nav.append("<td width=\"20\" align=\"center\"><a href=\"javascript:searchPage(").append(i).append(");\" class=\"link03\"><b>").append(i).append("</b></a></td>\n");
			}else{
				nav.append("<td width=\"20\" align=\"center\"><a href=\"javascript:searchPage(").append(i).append(");\" class=\"link03\">").append(i).append("</a></td>\n");
			}
		}
		nav.append("</tr >\n");
		nav.append("</table></td>\n");
		
		return nav.toString();
	}

}
